<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"> 
	
	<ui:composition
	template="template.xhtml">
	<ui:define name="content">

		<h:form id="gotDataForm">
			<p:layout id="layout">
				<p:layoutUnit position="west" resizable="true" size="300"
					minSize="40" maxSize="500">
					<p:dataList value="#{houseList.selectedHouse.members}" var="member"
						id="membersList" paginator="false" rows="15" type="none">

						<f:facet name="header">
                	House Members of <h:outputText
								value="#{houseList.selectedHouse.name}"></h:outputText>
						</f:facet>

						<p:commandButton icon="ui-icon-search" title="View Detail"
							ajax="true" actionListener="#{goTController.queryPersonInformation(member)}">
						</p:commandButton>

						<h:outputText value="#{member.name}" style="margin-left:10px" />
						<p:graphicImage value="icons/Icon_dead.png" rendered="#{!member.alive}"/>
						
						<br />
					</p:dataList>
					
					<p:commandButton id="addPerson" value="Add Person"
						onclick="dlg1.show();" type="button" />

				</p:layoutUnit>
				<p:layoutUnit id="centerUnit" position="center" header="Person Details">
					<p:outputPanel id="outputPersonData" style="text-align:center;"
						layout="block">
						<h:outputText
							value="#{houseList.selectedHouse.selectedPerson.name}, #{houseList.selectedHouse.selectedPerson.yearOfBirth}"
							id="personDetail" style="margin-left:10px" />
						<p:dataList
							value="#{houseList.selectedHouse.selectedPerson.siblings}"
							var="sibling" id="siblingsList" paginator="false" rows="10"
							type="none">
							<f:facet name="header">
    							Siblings
    						</f:facet>

							<p:commandLink ajax="true"
								actionListener="#{goTController.queryPersonInformation(sibling)}">
								<h:outputText value="#{sibling.name}" style="margin-left:10px" />
							</p:commandLink>

						</p:dataList>
						
						<p:dataList
							value="#{houseList.selectedHouse.selectedPerson.children}"
							var="child" id="childrenList" paginator="false" rows="10"
							type="none">
							<f:facet name="header">
    							Children
    						</f:facet>

							<p:commandLink ajax="true"
								actionListener="#{goTController.queryPersonInformation(child)}">
								<h:outputText value="#{child.name}" style="margin-left:10px" />
							</p:commandLink>

						</p:dataList>

						<p:dataList
							value="#{houseList.selectedHouse.selectedPerson.heirOf}"
							var="heir" id="heirOfList" paginator="false" rows="10"
							type="none">
							<f:facet name="header">
    							Inherits from
    						</f:facet>
							<p:commandLink ajax="true"
								actionListener="#{goTController.queryPersonInformation(heir)}">
								<h:outputText value="#{heir.name}" style="margin-left:10px" />
							</p:commandLink>

						</p:dataList>

						<p:dataList
							value="#{houseList.selectedHouse.selectedPerson.titles}"
							var="title" id="titlesList" paginator="false" rows="10"
							type="none">
							<f:facet name="header">
    							Titles
    						</f:facet>
							<h:outputText value="#{title}" style="margin-left:10px" />
						</p:dataList>
						
						<p:panel header="Other Informations">
							<p:panelGrid columns="2" style="margin: 0 auto;">
								
								<h:outputText value="Father" style="background-color:\#a9a9a9" />
								<p:commandLink ajax="true"
								actionListener="#{goTController.queryPersonInformation(houseList.selectedHouse.selectedPerson.father)}">
								<h:outputText value="#{houseList.selectedHouse.selectedPerson.father.name}" style="margin-left:10px" />
								</p:commandLink>
								
								<h:outputText value="Mother" style="background-color:\#a9a9a9" />
								<p:commandLink ajax="true"
								actionListener="#{goTController.queryPersonInformation(houseList.selectedHouse.selectedPerson.mother)}">
								<h:outputText value="#{houseList.selectedHouse.selectedPerson.mother.name}" style="margin-left:10px" />
								</p:commandLink>
							
								<h:outputText value="Spouse"/>
								<p:commandLink ajax="true"
								actionListener="#{goTController.queryPersonInformation(houseList.selectedHouse.selectedPerson.spouse)}">
								<h:outputText value="#{houseList.selectedHouse.selectedPerson.spouse.name}" style="margin-left:10px" />
								</p:commandLink>
							
							</p:panelGrid>
						</p:panel>

						<h:outputText
							value="#{houseList.selectedHouse.selectedPerson.inheritanceStatus}"
							style="margin-left:10px" />
				
						</p:outputPanel>
	
					<p:commandButton id="killPerson" value="Kill Person"
						style="margin: 0 auto;" actionListener="#{goTController.switchPersonStatus}" />
					<p:commandButton id="assignSpouse" value="Marriage"
						onclick="dlgHasSpouse.show();" type="button" />
					<p:commandButton id="assignTitle" value="Add Title"
						onclick="dlgHasTitle.show();" type="button" />
					
				</p:layoutUnit>
			</p:layout>
		</h:form>

		<p:dialog id="addDialog" header="Add Person" widgetVar="dlg1">
			<h:form>
				<table> <tr> <td>
				<h:outputText value="Name" /></td> <td>
				<p:inputText name="personName" value="#{inputPerson.name}" /></td> </tr> <tr>
				<td>
				<h:outputText value="Father" /></td> <td> <p:selectOneMenu
					value="#{inputPerson.fatherName}">
					<f:selectItems value="#{inputPerson.men}" />
				</p:selectOneMenu> </td> </tr> <tr> <td>
				<h:outputText value="Mother" /></td> <td> <p:selectOneMenu
					value="#{inputPerson.motherName}">
					<f:selectItems value="#{inputPerson.women}" />
				</p:selectOneMenu> </td> </tr> <tr> <td>
				<h:outputText value="Sex" /></td> <td> <p:selectOneRadio
					id="options" value="#{inputPerson.sex}">
					<f:selectItem itemLabel="Man" itemValue="Man" />
					<f:selectItem itemLabel="Woman" itemValue="Woman" />
				</p:selectOneRadio> </td> </tr> <tr> <td>
				<h:outputText value="Year of Birth" /></td> <td>
				<p:inputText name="yearOfBirth" value="#{inputPerson.age}" /></td> </tr> <tr>
				<td>
				<p:commandButton value="Add Person"
					actionListener="#{goTController.addPerson}"/></td> </tr> </table>
			</h:form>
		</p:dialog>
		
		<p:dialog id="assignSpouseDialog" header="Marry to" widgetVar="dlgHasSpouse">
			<h:form>
				<table> <tr> <td>
				<h:outputText value="Spouse" /></td> <td> <p:selectOneMenu
					value="#{inputHasSpouse.personTwo}">
					<f:selectItems value="#{inputHasSpouse.personList}" />
				</p:selectOneMenu> </td> </tr> 
				<tr> <td>
				<p:commandButton value="Set Spouse"
					actionListener="#{goTController.assignSpouse}" /></td> </tr> </table>			
			</h:form>
		</p:dialog>
		
		<p:dialog id="assignTitleDialog" header="Assign Title" widgetVar="dlgHasTitle">
			<h:form>
				<table> <tr> <td>
				<h:outputText value="Title" /></td> <td> <p:selectOneMenu
					value="#{inputHasTitle.title}">
					<f:selectItems value="#{inputHasTitle.titleList}" />
				</p:selectOneMenu> </td> </tr> 
				<tr> <td>
				<p:commandButton value="Assign Title"
					actionListener="#{goTController.assignTitle}" /></td> </tr> </table>			
			</h:form>
		</p:dialog>
		


	</ui:define>
</ui:composition> </html>